package com.improvess.rna.som.output;

import java.awt.BorderLayout;
import java.awt.HeadlessException;
import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;

import com.improvess.rna.som.DataSet;
import com.improvess.rna.som.RedeSOM;

@SuppressWarnings("serial")
public class ShowNet extends JFrame {

	private RedeSOM redeSOM;
	private int[] registros;
	private String[] clazzes;
	private DataSet dataSet;

	public ShowNet() throws HeadlessException {
		super("SOM Net");
		init();
	}

	public DataSet getDataSetTreinamento() {
		return dataSet;
	}

	public void setDataSetTreinamento(DataSet dataSetTreinamento) {
		this.dataSet = dataSetTreinamento;
		this.registros = null;
		this.clazzes = null;
	}

	

	public void setRegistros(int[] registros) {
		this.registros = registros;
	}

	public void setClazzes(String[] clazzes) {
		this.clazzes = clazzes;
	}

	public int[] getRegistros() {
		return registros;
	}

	public String[] getClazzes() {
		return clazzes;
	}

	public RedeSOM getRedeSOM() {
		return redeSOM;
	}

	public void setRedeSOM(RedeSOM redeSOM) {
		this.redeSOM = redeSOM;
		this.registros = null;
		this.clazzes = null;
	}

	private void init() {
		Image img = new ImageIcon(this.getClass().getResource(
				"addressbook32.png")).getImage();
		this.setIconImage(img);
		this.setExtendedState(JFrame.MAXIMIZED_BOTH);
		this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		this.addWindowListener(new java.awt.event.WindowAdapter() {
			public void windowClosing(java.awt.event.WindowEvent e) {
				toClose();
			}
		});

		this.setLayout(new BorderLayout());

		JMenuBar barraMenu = new BarraMenu(this);
		Panel panel = new Panel(this);
		StatusBar statusBar = new StatusBar();

		this.getContentPane().add(barraMenu, BorderLayout.NORTH);
		this.getContentPane().add(panel, BorderLayout.CENTER);
		this.getContentPane().add(statusBar, BorderLayout.SOUTH);
	}

	public void toClose() {

		int selectedOption = JOptionPane.showConfirmDialog(null,
				"Do you wish to close SOM application?", "Attention:",
				JOptionPane.YES_NO_OPTION);
		if (selectedOption == JOptionPane.YES_OPTION) {

			System.exit(0);
		}
	}

}
